package chap06.task6_4;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.io.*;

/**
 * @author Administrator
 */
public class Task6_4 {
    public static void main(String[] args) throws IOException {
        long start = System.currentTimeMillis();
        method4("D:\\copy.mp4", "copy.mp4");
        method2("D:\\copy.mp4", "copy4.mp4");
        method1("D:\\copy.mp4", "copy4.mp4");
        method3("D:\\copy.mp4", "copy4.mp4");
        long end = System.currentTimeMillis();
        System.out.println("共耗时：" + (end - start) + "毫秒");
    }

    private static void method3(String s, String s1) throws IOException {
        FileInputStream f1=new FileInputStream("D:\\copy.mp4");
        FileOutputStream f2=new FileOutputStream("copy.mp4");
        int by=0;
        while ((by=f1.read())!=-1){
            f2.write(by);
        }
        f1.close();
        f2.close();
    }

    private static void method1(String s, String s1)throws IOException {
        BufferedInputStream f1=new BufferedInputStream(new FileInputStream("D:\\copy.mp4"));
        BufferedOutputStream f2=new BufferedOutputStream(new FileOutputStream("copy.mp4"));
      int by=0;
      while ((by=f1.read())!=-1){
          f2.write(by);
      }
      f1.close();
      f2.close();
    }

    private static void method4(String s, String s1) throws IOException{
        BufferedInputStream f1=new BufferedInputStream(new FileInputStream("D:\\copy.mp4"));
        BufferedOutputStream f2=new BufferedOutputStream(new FileOutputStream("copy.mp4"));
        byte[] bys= new byte[1024];
        int len=0;
        while ((len=f1.read(bys))!=-1){
            f2.write(bys,0,len);
        }
        f1.close();
        f2.close();
    }

    private static void method2(String s, String s1) throws IOException{
        FileInputStream f1=new FileInputStream("D:\\copy.mp4");
        FileOutputStream f2=new FileOutputStream("copy.mp4");
        byte[] bys=new byte[2048];
        int len=0;
        while ((len=f1.read(bys))!=-1){
            f2.write(bys,0,len);
        }
        f1.close();
        f2.close();
    }

}
